﻿// ReSharper disable ClassNeverInstantiated.Global

namespace DYH.Extensions.DependencyInjection;

/// <summary>
/// 抽象类，用于定义依赖注入属性的基础结构。
/// </summary>
/// <param name="interfaceType">可选参数，指定要注入的接口类型。</param>
public abstract class DependencyInjectionAttribute(Type? interfaceType = null) : Attribute
{
    /// <summary>
    /// 获取注入的接口类型。
    /// </summary>
    public Type? InterfaceType { get; } = interfaceType;
}

/// <summary>
/// 特性，用于标记类为单例依赖注入。
/// </summary>
/// <param name="interfaceType">可选参数，指定要注入的接口类型。</param>
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
public sealed class SingletonDIAttribute(Type? interfaceType = null)
    : DependencyInjectionAttribute(interfaceType);

/// <summary>
/// 特性，用于标记类为暂态依赖注入。
/// </summary>
/// <param name="interfaceType">可选参数，指定要注入的接口类型。</param>
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
public sealed class TransientDIAttribute(Type? interfaceType = null)
    : DependencyInjectionAttribute(interfaceType);

/// <summary>
/// 特性，用于标记类为作用域依赖注入。
/// </summary>
/// <param name="interfaceType">可选参数，指定要注入的接口类型。</param>
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
public sealed class ScopedDIAttribute(Type? interfaceType = null)
    : DependencyInjectionAttribute(interfaceType);